Attribute VB_Name = "modAccessFunc"
Option Explicit

'Access Connection Variables
Public AccConn As New ADODB.Connection
Public AccCmd As New ADODB.Command
Public sAccConnString  As String   'global connect string


'''''''''''''''''''''''''''''''''''''''''''''''''''''
'
'   Cleans recordsets, closes connection
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub CloseAccConn(Optional RSx1 As ADODB.Recordset, Optional RSx2 As ADODB.Recordset, _
              Optional RSx3 As ADODB.Recordset, Optional RSx4 As ADODB.Recordset)

    If Not RSx1 Is Nothing Then CloseSub RSx1
    If Not RSx2 Is Nothing Then CloseSub RSx2
    If Not RSx3 Is Nothing Then CloseSub RSx3
    If Not RSx4 Is Nothing Then CloseSub RSx4
    
    If Not AccConn Is Nothing Then
        Set AccCmd = Nothing
        If AccConn.State <> 0 Then AccConn.Close
        Set AccConn = Nothing
    End If


End Sub


Sub CloseSub(rsX As ADODB.Recordset)
    On Error Resume Next
        If rsX.State <> 0 Then rsX.Close
        Set rsX = Nothing
    Err.Clear
End Sub


'''''''''''''''''''''''''''''''''''''''''''''''''''''
'
'   Opens connection for Access DB containing MAS90 data
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub OpenAccConn()

    If AccConn Is Nothing Then
        Set AccConn = New ADODB.Connection
    End If

    '*************** for access
    'sAccConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\192.168.0.250\IPSLogic\Source\data.mdb"
    'sAccConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\RMFP2600\IPSLogic\Source\data.mdb"
    'sAccConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\All Users\Desktop\Clients\Freshies\ScannerRF\Source 9.29.06_SQL\data.mdb"
    sAccConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Rfsyngistic\synRF.mdb"
    
    
    If AccConn.State <> 1 Then
        AccConn.Open sAccConnString
        Set AccCmd.ActiveConnection = AccConn
    End If


End Sub


'''''''''''''''''''''''''''''''''''''''''''''''''''''
'                                                   '
'   Executes any Access Action Query or Code        '
'                                                   '
'''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub execAccess(strSql As String)

    Dim sqlCmd As New ADODB.Command
    
    'sqlCmd.CommandType = adCmdStoredProc
    sqlCmd.CommandText = strSql
    
    'OpenAccConn
    sqlCmd.ActiveConnection = AccConn
    sqlCmd.Execute
    'CloseAccConn
    

End Sub
